package com.wn.servlet.demo02;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;

/**
 * @author yellow Docter
 * @date 2022 -06-29
 * @desc
 */
public class Demo02 {

    public static void main(String[] args) throws UnsupportedEncodingException {

        //编码  把汉字转成url编码
        String str = "天气不错";
        String encode = URLEncoder.encode(str, "utf-8");
        System.out.println(encode);

        // 解码   把url编码 解析成字符串
        String decode = URLDecoder.decode(encode, "utf-8");
        System.out.println(decode);

    }

}
